/*********************************************************************************************************************
 * COPYRIGHT NOTICE
 * Copyright (c) 2018,逐飞科技
 * All rights reserved.
 * 技术讨论QQ群：	一群：179029047(已满)
 *					二群：244861897(已满)
 *					三群：824575535
 *
 * 以下所有内容版权均属逐飞科技所有，未经允许不得用于商业用途，
 * 欢迎各位使用并传播本程序，修改内容时必须保留逐飞科技的版权声明。
 *
 * @file			seekfree_ms5611.h
 * @company			成都逐飞科技有限公司
 * @author			逐飞科技(QQ3184284598)
 * @version			查看doc内version文件 版本说明
 * @Software		IAR 8.3 or MDK 5.24
 * @Taobao			https://seekfree.taobao.com/
 * @date			2020-03-25
 * @note			本文件作为IOT开发板seekfree_ms5611传感器API
 ********************************************************************************************************************/
#ifndef _SEEKFREE_MS5611_H_
#define _SEEKFREE_MS5611_H_

#ifdef IOT_BOARD
#include "iot_flexcomm_iic.h"
#else
#include "zf_iic.h"
#endif

// 定义MPU6050内部地址

#define	I2C_MS5611						0b1110111	//IIC写入时的地址字节数据，+1为读取

// I2C commands of chip
#define MS5xxx_CMD_RESET				0x1E	// perform reset
#define MS5xxx_CMD_ADC_READ				0x00	// initiate read sequence
#define MS5xxx_CMD_ADC_CONV				0x40	// start conversion
#define MS5xxx_CMD_ADC_D1				0x00	// read ADC 1
#define MS5xxx_CMD_ADC_D2				0x10	// read ADC 2
#define MS5xxx_CMD_ADC_256				0x00	// set ADC oversampling ratio to 256
#define MS5xxx_CMD_ADC_512				0x02	// set ADC oversampling ratio to 512
#define MS5xxx_CMD_ADC_1024				0x04	// set ADC oversampling ratio to 1024
#define MS5xxx_CMD_ADC_2048				0x06	// set ADC oversampling ratio to 2048
#define MS5xxx_CMD_ADC_4096				0x08	// set ADC oversampling ratio to 4096
#define MS5xxx_CMD_PROM_RD				0xA0	// initiate readout of PROM registers

#ifdef IOT_BOARD
void ms5611_init (iot_flexcomm_index_list Index);
void ms5611_send_cmd (iot_flexcomm_index_list Index,uint8_t cmd);
void ms5611_read_prom (iot_flexcomm_index_list Index);
uint16_t ms5611_calc_crc4 (iot_flexcomm_index_list Index);
uint16_t ms5611_read_crc4 (iot_flexcomm_index_list Index);
uint16_t ms5611_read_databuffer (iot_flexcomm_index_list Index, uint8_t index);
uint32_t ms5611_read_adc (iot_flexcomm_index_list Index, uint8_t cmd);
void ms5611_read_out (iot_flexcomm_index_list Index);
double ms5611_get_temperature (iot_flexcomm_index_list Index);
double ms5611_get_pressure (iot_flexcomm_index_list Index);
#else
void ms5611_init (flexcomm_index_list Index);
void ms5611_send_cmd (flexcomm_index_list Index,uint8_t cmd);
void ms5611_read_prom (flexcomm_index_list Index);
uint16_t ms5611_calc_crc4 (flexcomm_index_list Index);
uint16_t ms5611_read_crc4 (flexcomm_index_list Index);
uint16_t ms5611_read_databuffer (flexcomm_index_list Index, uint8_t index);
uint32_t ms5611_read_adc (flexcomm_index_list Index, uint8_t cmd);
void ms5611_read_out (flexcomm_index_list Index);
double ms5611_get_temperature (flexcomm_index_list Index);
double ms5611_get_pressure (flexcomm_index_list Index);
#endif

#endif
